home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c / 197 < prev    next >
Internet Message Format  |  1996-08-06  |  5KB

  1. Path: ix.netcom.com!netnews
  2. From: miker3@ix.netcom.com (Mike Rubenstein)
  3. Newsgroups: comp.lang.c++,comp.lang.c,comp.std.c
  4. Subject: Re: Hungarian notation
  5. Date: Sat, 27 Jan 1996 03:00:21 GMT
  6. Organization: Netcom
  7. Message-ID: <31098190.8106176@nntp.ix.netcom.com>
  8. References: <30C40F77.53B5@swsbbs.com> <4d2ok0$69s@beach.and.nl> <4dtv3gINNo9u@keats.ugrad.cs.ubc.ca> <SPENCER.96Jan22113215@zorgon.ERA.COM> <4e1nd8$hv0@solutions.solon.com> <3104bfc8.132251392@nntp.ix.netcom.com> <dewar.822407919@schonberg> <3106260f.224013120@nntp.ix.netcom.com> <4e6oj9$o02@news.xmission.com> <31077335.52859072@nntp.ix.netcom.com> <JSA.96Jan25190824@organon.com> <310842ad.6002240@nntp.ix.netcom.com> <JSA.96Jan26175507@organon.com>
  9. NNTP-Posting-Host: ix-dc17-13.ix.netcom.com
  10. X-NETCOM-Date: Fri Jan 26  7:00:35 PM PST 1996
  11. X-Newsreader: Forte Agent .99c/16.141
  12.  
  13. jsa@organon.com (Jon S Anthony) wrote:
  14.  
  15. NOTE:  I've removed all groups from this posting except comp.lang.c
  16. and comp.lang.c++ and have added cmp.std.c
  17.  
  18. Since I've added a new group, let me summarize a bit.  The discussion
  19. revolves around the result of converting a signed integral type to a
  20. smaller type when the value in the original cannot be represented in
  21. the new type.
  22.  
  23. I claim that ISO 6.2.1.2 requires that an implementation actually do
  24. such a conversion.  The implementor may choose the mapping.  Beside
  25. the usual throwing away of high order bits, possibilities include
  26. always using the value 0, or the largest possible value for the new
  27. type, or, even, a random value.
  28.  
  29. However, I claim that a conversion is required -- the implementation
  30. must come up with a value that can be represented in the new type and
  31. use that.  It may not do other things like, as one person claimed,
  32. deleting the system disk even if such action is documented.
  33.  
  34. > In article <310842ad.6002240@nntp.ix.netcom.com> miker3@ix.netcom.com (Mike Rubenstein) writes:
  35. > > jsa@organon.com (Jon S Anthony) wrote:
  36. > > 
  37. > > > In article <31077335.52859072@nntp.ix.netcom.com> miker3@ix.netcom.com (Mike Rubenstein) writes:
  38. > > > 
  39. > > > > I think you're reading something into my post that isn't there.
  40. > > > > 
  41. > > > > What am I reading into the standard that's not there?  Nothing in my
  42. > > > > post suggests that defining the result as always 0 is illegal.  In
  43. > > > > fact, it is clearly legal.
  44. > > > > 
  45. > > > > But the standard does impose some restrictions on the definition.  The
  46. > > > > definition must specify that the subject type is converted to the
  47. > > > > object type.  It must not produce side-effects.
  48. > > > > 
  49. > > > > Please reread my post; I was responding to the statement that the
  50. > > > > definition could be to delete the system disk.  That is out of bounds
  51. > > > > for the definition and I said so.  I did not say that defining the
  52. > > > > result to be 0 is out of bounds.
  53. > > > 
  54. > > > Face it.  You just plain got it wrong.  Deleting the system disk is
  55. > > > perfectly within bounds.  Stupid, for sure, as no one in their right
  56. > > > mind would use such a compiler, but perfectly legal.
  57. > > 
  58. > > Please cite anything in the standard that supports your position.  I
  59. > > can find nothing in the standard that gives an implementation that
  60. > > license.
  61. > > 
  62. > > Insults do not prove a point -- quotes from the standard do.  I've
  63. > > shown the passages that support my position.
  64. > I don't see any insult here at all.  Sorry if you took it that way.
  65. > Here's the relevant passage yet again:
  66. >      When a value with integral type is demoted to a signed integer
  67. >      with smaller size or an unsigned integer is converted to its 
  68. >      corresponding signed integer, if the value cannot be 
  69. >      represented the result is implementation defined.
  70. > Now, the problem is (as James Kanze has pointed out) that the term
  71. > "result" which you believe to know the "correct" definition of, is not
  72. > defined.  Because of this it _could_ be taken as meaning "result of
  73. > the computation".  You take it as a given that it means "result of the
  74. > expression", i.e., its value.  But that is not clear, and so an
  75. > interpretation given the former reading would indeed allow for
  76. > virtually any sort of behavior as long as that behavior was
  77. > documented.  As James Kanze pointed out, a very _reasonable_
  78. > interpretation given this reading of "result" would be to to signal
  79. > (raise) an exception.
  80.  
  81. I've not seen Jame's post, but I look forward to seeing it.
  82.  
  83. But, I don't see how the standard permits throwing an exception.  ISO
  84. 6.2 says
  85.  
  86.     Several operators convert operand values from one type to 
  87.     another automatically.  This subclause specifies the result 
  88.     required from such an implicit conversion, as well as those 
  89.     that result from a cast operation (an explicit conversion).
  90.  
  91. It seems obvious to me that if one uses correctly a construction that
  92. the standard says converts a value from one type to another, then the
  93. implementation must convert the value from one type to another -- it
  94. may not do other things.  By definition (ISO 3.10)
  95. implementation-defined behavior only applies to a correct program
  96. construct and correct data.
  97.  
  98. I'm glad you intended no insult.  I'm afraid I just don't react well
  99. to ex cathedra statements that I am wrong, particularly when I have
  100. taken  care to give clear citations that I believe support my
  101. position.
  102.  
  103. Michael M Rubenstein
  104.